package com.hopu.v1.pojo.classes;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hopu.v1.pojo.common.Save;
import com.hopu.v1.pojo.common.Update;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * 学生表
 * @TableName t_student
 */
@TableName(value ="t_student")
@Data
public class Student implements Serializable {
    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 年龄
     */
    @TableField(value = "age")
    @NotNull(message = "年龄不能为空",groups = Update.class)
    private Integer age;

    /**
     * 学号
     */
    @TableField(value = "student_id")
    private String studentId;

    /**
     * 姓名
     */
    @TableField(value = "name")
    @Length(message = "姓名不低于2位", min = 2, groups = Update.class)
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]+$",message = "姓名格式不正确，不得低于2位中文",groups = Update.class)
    @NotBlank(message = "姓名不能为空",groups = Update.class)
    private String name;

    /**
     * 昵称
     */
    @TableField(value = "nickname")
    private String nickname;

    /**
     * 性别
     */
    @TableField(value = "gender")
    @NotBlank(message = "性别不能为空",groups = Update.class)
    private String gender;

    /**
     * 电话
     */
    @TableField(value = "telephone")
    @Pattern(regexp = "^1\\d{10}$",message = "手机号码格式不正确",groups = Update.class)
    @NotBlank(message = "手机号码不能为空",groups = Update.class)
    private String telephone;

    /**
     * 启用状态
     */
    @TableField(value = "status")
    private Integer status;

    /**
     * 毕业状态
     */
    @TableField(value = "status_graduation")
    private Integer statusGraduation;

    /**
     * 毕业时间
     */
    @TableField(value = "status_graduation_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate statusGraduationTime;

    /**
     * 头像
     */
    @TableField(value = "avatar")
    private String avatar;

    /**
     * 班级id
     */
    @TableField(value = "class_id")
    @NotNull(message = "班级Id不能为空",groups = Update.class)
    private String classId;

    /**
     * 学历
     */
    @TableField(value = "education")
    private String education;

    /**
     * 身份证号
     */
    @TableField(value = "id_card")
    @NotBlank(message = "身份证号不能为空",groups = Update.class)
    @Pattern(regexp = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)",message = "格式不正确", groups = Update.class)
    private String idCard;

    /**
     * 出生日期
     */
    @TableField(value = "birthday")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate birthday;

    /**
     * 籍贯
     */
    @TableField(value = "native_place")
    private String nativePlace;

    /**
     * 政治面貌
     */
    @TableField(value = "political_outlook")
    private String politicalOutlook;

    /**
     * 家庭住址
     */
    @TableField(value = "address")
    private String address;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}